package com.hdl.design.pattern.factory.simple;

/**
 * 类名 OperationFactory
 * 描述 工厂类
 * @author hedonglin
 * @version 1.0
 * @date 2019/9/25 9:48
 */
public class OperationFactory {
    /**
     * 方法描述: 实例化运算操作
     * @param operate 操作符
     * @return {@link AbstractOperation} 抽象操作类
     * @author hedonglin
     * @date 2019/10/3 11:12
     */
    public static AbstractOperation createOperate(String operate) {
        AbstractOperation operation = null;
        switch (operate) {
            case "+":
                operation = new OperationAdd();
                break;
            case "-":
                operation = new OperationSub();
                break;
            case "*":
                operation = new OperationMul();
                break;
            case "/":
                operation = new OperationDiv();
                break;
            default:
                break;
        }
        return operation;
    }
}
